<?php
/**
 * Created by PhpStorm.
 * User: stupboy
 * Date: 2018/5/28
 * Time: 16:00
 * Mail:87658989@qq.com
 */

namespace app\adminapi\filter;
use app\base\filter\Common;
use think\Config;

class DriverList extends Common
{
    public $field = [
        'a.driver_id'    => '司机id||int|1',
        'a.company_id'=> '公司id||int|1',
        'a.name'         => '姓名||string|1',
        'a.id_card'      => '身份证号码',
        'a.age'          => '年龄',
        'a.sex'          => '性别',
        'a.birthday'     => '生日',
        'a.phone'        => '电话||string|1',
        'a.add'          => '地址',
        'a.head_img'=>'头像',
        'half_body_img'=>'半身照片',
        'body_img'=>'全身照片',
        'insurance_img'=>'保险图片',
        'contract_img'=>'合同照片',
        'id_img'=>'身份证正面',
        'id_img_back'=>'身份证背面',
        'driver_license_img'=>'驾驶证正面',
        'driver_license_img_back'=>'驾驶证背面',
        'residence_permit_img'=>'居住证',
        'a.original_position'=>'职位',
        'a.language'=>'语言 1:"普通话",2:"闽南话",3:"广东话",4:"英语",5:"日语",6:"韩语"',
        'a.wechat'=>'微信',
        'a.alipay'=>'支付宝',
        'a.driving_age'=>'驾龄',
        'a.bank_card'=>'银行卡号',
        'a.work_state'=>'司机状态，1：执行任务中，2：有预约订单，3：听单中，4：下班||int|1',
        'a.driver_no'=>'工号',
        'a.bank'=>'银行',
        'a.state'=>'账号状态',
        'a.star'=>'星级',
        'a.score'=>'评分',
        'a.rate'=>'接单率',
        'a.order_count'=>'订单数',
        'a.lon'=>'当前经度',
        'a.lat'=>'当前纬度',
        'a.update_time'=>'更新时间',
        'a.car_id'=>'默认绑定车辆id',
        'a.task_time'=>'任务开始时间',
        'b.company_name'=>'单位名称||string|1',
        'b.short_name'=>'简称||string|1',
        'b.address'=>'单位地址',
        'b.linkman'=>'单位联系人',
        'b.remark'=>'单位备注',
        'b.isreform'=>'是否参改单位',
        'c.number'=>'车牌',
        'c.colour'=>'车身颜色',
    ];

    public $other = [
        'language_enum' => '语言原始枚举值||string|0',
    ];

    public function checkData($data){
        $newData  = [];
        $language = Config::get('base.languages');
        foreach ($data as $value){
            if(isset($value['language'])){
                $value['language_enum'] = $value['language']; // 保留原枚举值
                $arr = explode(',',$value['language']);
                $str = [];
                foreach ($arr as $vv){
                    isset($language[$vv]) && $str[] = $language[$vv];
                }
                $value['language'] = implode(',',$str);
            }
            $newData[] = $value;
        }
        return $newData;
    }
}